//EJERCICIO 1
Scanner sc = new Scanner(System.in);
System.out.println("Introduce el radio: ");
int radio = sc.nextInt();
System.out.println("El area de la circunferencia es: " + (Math.PI * radio * radio));

//EJERCICIO 2
Scanner sc = new Scanner(System.in);
System.out.println("Introduce el numero en cm: ");
int cantidad = sc.nextInt();
System.out.println("El numero pasado a metros es: " + (cantidad / 100));

//EJERCICIO 3
Scanner sc = new Scanner(System.in);
System.out.println("Introduce el primer cateto: ");
double cateto1 = sc.nextDouble();
System.out.println("Introduce el segundo cateto: ");
double cateto2 = sc.nextDouble();
System.out.println("La hipotenusa es: " + (Math.sqrt(cateto1 * cateto1 + cateto2 * cateto2)));

//EJERCICIO 4
Scanner sc = new Scanner(System.in);
System.out.println("Introduce un numero: ");
int x = sc.nextInt();
if(x % 2 == 0) {
	System.out.println("Es par");
}else {
	System.out.println("No es par");
}

//EJERCICIO 5
Scanner sc = new Scanner(System.in);
System.out.println("Introduce una letra: ");
char c = sc.nextLine().charAt(0);
if((int)c >= (int)'a' && (int)c <= (int)'z') {
	System.out.println("Minuscula");
}else {
	System.out.println("Mayuscula");
}

//EJERCICIO 6
Scanner sc = new Scanner(System.in);
System.out.println("Jugador A: ");
int puntosA = sc.nextInt();
int puntosB = sc.nextInt();
		
if(puntosA > 7 || puntosB > 7) {
	System.out.println("Puntiacion invalida");
}else if((puntosA < 5 && puntosB > 6) || (puntosB < 5 && puntosA > 6)) {
	System.out.println("Puntiacion invalida");
}else if(puntosA == 6 && puntosB < 5) {
	System.out.println("Gana A");
}else if(puntosB == 6 && puntosA < 5) {
	System.out.println("Gana B");
}else if(puntosA == 7 && puntosB >= 5 && puntosB <= 6) {
	System.out.println("Gana A");
}else if(puntosB == 7 && puntosA >= 5 && puntosA <= 6) {
	System.out.println("Gana B");
}else if((puntosA == puntosB && puntosA < 7) || (puntosA != puntosB && puntosA < 7)) {
	System.out.println("El set no se ha acabado");
}else {
	System.out.println("Puntuacion invalida");
}

//EJERCICIO 7
for(int i = 0; i <= 10; i++) {
	System.out.println("3 x " + i + " = " + (3 * i));
}

//EJERCICIO 8
Scanner sc = new Scanner(System.in);
System.out.println("Introduce un numero: ");
int x = sc.nextInt();
		
for(int i = 0; i <= 10; i++) {
	System.out.println(x + " ^ " + i + " = " + Math.pow(x, i));
}

//EJERCICIO 9
Scanner sc = new Scanner(System.in);
System.out.println("Introduce un numero: ");
int x = sc.nextInt();
		
int i = 1;
boolean esPrimo = true;
while(i <= x && esPrimo) {
	if((i != 1 && i != x) && (x % i == 0)) {
		esPrimo = false;
		System.out.println("El numero no es primo");
	}
	i++;
			
	if(esPrimo) {
		System.out.println("es primo");
	}
}

//EJERCICIO 10
int contador = 0;
		
for(int i = 0; i <= 50; i++) {
	if(i % 2 == 0) {
		System.out.println(i + " es par");
		contador++;
	}
}
		
System.out.println("Hay " + contador + " numeros pares entre 0 y 50");

//EJERCICIO 11
for(int i = 0; i < 4; i++) {
	for(int j = 0; j < 10; j++) {
		if(i == 0 || i == 3) {
			System.out.println("*");
		}else {
			if(j == 0 || j == 9) {
				System.out.println("|");
			}else {
				System.out.println(" ");
			}
		}
	}
	System.out.println();
}

//EJERCICIO 12
int sum = 0;
for(int i = 0; i <= 100; i++) {
	sum += i;
}
System.out.println("La suma es " + sum);

//EJERCICIO 13
System.out.println("Escribe s para salir del bucle o c para continuar");
Scanner sc = new Scanner(System.in);
char c = sc.nextLine().charAt(0);
		
while(c != 's') {
	System.out.println("Sigues en el bucle");
	System.out.println("Escribe s para salir del bucle o c para continuar");
	c = sc.nextLine().charAt(0);
}
		
System.out.println("Has salido del bucle");

//EJERCICIO 14
System.out.println("Introduce una palabra o frase: ");
Scanner sc = new Scanner(System.in);
		
System.out.println(sc.nextLine().length());

//EJERCICIO 15
System.out.println("Introduce una palabra o frase: ");
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int contador = 0;
		
for(int i = 0; i < s.length(); i++) {
	if(s.charAt(i) != ' ') {
		contador++;
	}
}
		
System.out.println(contador);

//EJERCICIO 16
System.out.println("Introduce una palabra o frase: ");
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
int contador = 0;
		
for(int i = 0; i < s.length(); i++) {
	if(s.charAt(i) == 'a') {
		contador++;
	}
}
		
System.out.println(contador);

//EJERCICIO 17
System.out.println("Introduce 10 numeros, pero si introduces un 0 no podras meter mas: ");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[]arr = new int[10];
int i = 0;
		
while(n != 0) {
	arr[i] = n;
	System.out.println("Introduce el siguiente: ");
	n = sc.nextInt();
	i++;
}
		
int mayor = arr[0];
for (int j = 0; j < arr.length; j++) {
	if(arr[j] > mayor) {
		mayor = arr[j];
	}
}
		
System.out.println("El mayor es: " + mayor);

//EJERCICIO 18
System.out.println("Introduce 10 numeros, pero si introduces un 0 no podras meter mas: ");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[]arr = new int[10];
int i = 0;
		
while(n != 0) {
	arr[i] = n;
	System.out.println("Introduce el siguiente: ");
	n = sc.nextInt();
	i++;
}
		
int sum = 0;
for (int j = 0; j < arr.length; j++) {
	sum += arr[j];
}
		
System.out.println("La suma total es: " + sum);

//EJERCICIO 19
String[] nombres = new String[8];
Scanner sc = new Scanner(System.in);
		
for (int i = 0; i < nombres.length; i++) {
	System.out.println("Introduce el nombre del equipo numero " + (i + 1));
	nombres[i] = sc.nextLine();
}
		
int cont = 0;
int[] ganadores1 = new int[4];
int pos = 0;
System.out.println("Primera ronda");
while(cont < 7) {
	System.out.println("1. " + nombres[cont] + " - 2. " + nombres[cont + 1] + ": ");
	int opcion = sc.nextInt();
	if(opcion == 1) ganadores1[pos] = cont;
	else ganadores1[pos] = cont + 1;
			
	cont += 2;
	pos++;
}
		
cont = 0;
pos = 0;
int[] ganadores2 = new int[2];
System.out.println("Segunda ronda");
while(cont < 3) {
	System.out.println("1. " + nombres[ganadores1[cont]] + " - 2. " + nombres[ganadores1[cont + 1]] + ": ");
	int opcion = sc.nextInt();
	if(opcion == 1) ganadores2[pos] = ganadores1[cont];
	else ganadores2[pos] = ganadores1[cont + 1];
			
	cont += 2;	
	pos++;
}
		
System.out.println("Tercera ronda");
System.out.println("1. " + nombres[ganadores2[0]] + " - 2. " + nombres[ganadores2[1]] + ": ");
int opcion = sc.nextInt();
int ganador;
if(opcion == 1)	ganador = ganadores2[0];
else ganador = ganadores2[1];
		
System.out.println("Finalmente el ganador es: " + "!" + nombres[ganador] + "!");

//EJERCICIO 20
public static void tablaDel(int n) {
	for(int i = 0; i <= 10; i++) {
		System.out.println(n + " x " + i + " = " + (n * i));
	}
}

//EJERCICIO 21
public static boolean esPos(int n) {
	if(n >= 0) {
		return true;
	}else {
		return false;
	}
}
	
public static void posOneg(int n) {
	if(esPos(n)) {
		System.out.println("Es positivo");
	}else {
		System.out.println("Es negativo");
	}
}

//EJERCICIO 22
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
		
while(!s.equals("salir")) {
	repetidor(s);
	s = sc.nextLine();
}

public static void repetidor(String s) {
	System.out.println(s + "(IA)");
}

//EJERCICIO 23
int[][] ESO = new int[4][3];
		
Scanner sc = new Scanner(System.in);
int opcion = 0;
		
while(opcion != 4) {
	System.out.println("(1) Anadir alumno");
	System.out.println("(2) Eliminar alumno");
	System.out.println("(3) Alumnos en clase");
	System.out.println("(4) Salir");
			
	opcion = sc.nextInt();
	switch(opcion) {
	case 1 : System.out.println("Primero elige el curso: ");
		 int anadirCurso = sc.nextInt();
		 System.out.println("Ahora la clase (A = 1, B = 2, C = 3)");
		 int anadirClase = sc.nextInt();
		 ESO[anadirCurso][anadirClase]++;
		break;
	case 2 : System.out.println("Primero elige el curso: ");
		 int eliminarCurso = sc.nextInt();
		 System.out.println("Ahora la clase (A = 1, B = 2, C = 3)");
		 int eliminarClase = sc.nextInt();
		 if(ESO[eliminarCurso][eliminarClase] > 0) {
		 	 ESO[eliminarCurso][eliminarClase]--;
		 }
		break;
	case 3 : System.out.println("Primero elige el curso: ");
		 int infoCurso = sc.nextInt();
		 System.out.println("Ahora la clase (A = 1, B = 2, C = 3)");
		 int infoClase = sc.nextInt();
		 System.out.println(ESO[infoCurso][infoClase] + " alumnos");
		break;
	case 4 : System.out.println("Saliendo del sistema");
		break;
	default : System.out.println("Opcion no valida");
	}
}